function strToArray(str) {
    if (str) {
        return eval(`(${str})`)
    }
    return [];
}
export function APPEND_SENTENCE_LIST(state, result) {
    result.map(item => {
        if (item.tag) {
            item.tag = strToArray(item.tag)
        }
        if (item.tagId) {
            item.tagId = strToArray(item.tagId)
        }
    });
    state.sentenceList = state.sentenceList.concat(result);
    state.loadStatus = 'complete';
    if (result.length === 0) {
        state.loadStatus = 'noData';
    }
}
export function SET_SENTENCE_LIST(state, result) {
    result.map(item => {
        if (item.tag) {
            item.tag = strToArray(item.tag)
        }
        if (item.tagId) {
            item.tagId = strToArray(item.tagId)
        }
    });
    state.sentenceList = result;
    state.loadStatus = 'complete';
    if (result.length === 0) {
        state.loadStatus = 'noData';
    }
}
export function SET_NEXTPAGE_OPT(state, result) {
    state.actionOpt.pn += 1;
}
export function SET_SPECIAL_LIST(state, result) {
    state.specialList = result;
}
export function SET_SENTENCE_CONTENT(state, content) {
    state.sentenceDetail = content;
}
export function UPDATE_SEARCH_VAL(state, content) {
    state.searchVal = content;
}
export function SET_CATEGORY_LIST(state, content) {
    state.categoryList = content;
}
export function SET_SPECIAL_DETAILS(state, content) {
    state.specialDetails = content;
}
export function SET_SPECIAL_COUNT(state, count) {
    state.specialCount = count;
}
export function SET_SPECIAL_MAXPAGE(state, count) {
    state.specialMaxPage = count;
}
export function SET_SEARCH_RESULT(state, result) {
    state.searchResult = result.data || [];
    state.searchResultCount = result.count || 0;
    state.searchResultMaxPage = result.maxPage || 0;
}
export function SET_LOAD_STATUS(state, status) {
    state.loadStatus = status;
}
export function SET_SENTENCE_THUMBSUP(state, result) {
    state.thumbsUp.sentence = result;
}
export function SET_COMMENT_THUMBSUP(state, result) {
    state.thumbsUp.comment = result;
}
export function SET_SENTENCE_COLLECT(state, result) {
    state.collect = result;
}
// 更新点赞数据
export function UPDATE_THUMBSUP_NUM(state, params) {
    let sentenceId = params.typeId;
    let sentenceList = state.sentenceList;
    state.sentenceList = sentenceList.map(item => {
        if (item.id === sentenceId && params.status) {
            item.like += 1;
        }
        if (item.id === sentenceId && !params.status) {
            item.like -= 1;
        }
        return item;
    })
}
// 更新收藏数据
export function UPDATE_COLLECT(state, params) {
    let sentenceId = params.sentenceId;
    let sentenceList = state.sentenceList;
    state.collect = params.collectList;
    state.sentenceList = sentenceList.map(item => {
        if (item.id === sentenceId && params.status) {
            item.collect += 1;
        }
        if (item.id === sentenceId && !params.status) {
            item.collect -= 1;
        }
        return item;
    })
}
export function SET_SENTENCE_COMMONT(state, result) {
    state.sentenceCommont = result;
}
export function SET_SENTENCE_COMMONT_COUNT(state, result) {
    state.sentenceCommontCount = result;
}
export function SET_COLLECT_LIST(state, result) {
    result.map(item => {
        if (item.sentence.tag) {
            item.sentence.tag = strToArray(item.sentence.tag)
        }
        if (item.sentence.tagId) {
            item.sentence.tagId = strToArray(item.sentence.tagId)
        }
    });
    state.sentenceCollectList = result;
}
export function SET_PRAISE_LIST(state, result) {
    result.map(item => {
        if (item.sentence.tag) {
            item.sentence.tag = strToArray(item.sentence.tag)
        }
        if (item.sentence.tagId) {
            item.sentence.tagId = strToArray(item.sentence.tagId)
        }
    });
    state.sentencePraiseList = result;
}
export function SET_COLLECT_COUNT(state, result) {
    state.sentenceCollectCount = result;
}
export function SET_PRAISE_COUNT(state, result) {
    state.sentencePraiseCount = result;
}
export function SET_COLLECT_TOTALPAGE(state, result) {
    state.sentenceCollectTotalPage = result;
}
export function SET_PRAISE_TOTALPAGE(state, result) {
    state.sentencePraiseTotalPage = result;
}
